/*-
 * FCS.java          TP-Failure-Cause (TP-FCS)
 *
 * $LastChangedBy: stein $
 * $LastChangedRevision: 95 $
 * $LastChangedDate: 2007-02-13 16:19:24 +0000 (Tue, 13 Feb 2007) $
 * $HeadURL: svn://localhost/SMS/src/com/googlecode/attention/sms/pdu/FCS.java $
 *
 * Copyright (c) 2007, Stein Gunnar Bakkeby
 * All rights reserved.
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 *     * Redistributions of source code must retain the above copyright
 *       notice, this list of conditions and the following disclaimer.
 *     * Redistributions in binary form must reproduce the above copyright
 *       notice, this list of conditions and the following disclaimer in the
 *       documentation and/or other materials provided with the distribution.
 *     * Neither the name of Stein Gunnar Bakkeby nor the names of its
 *       contributors may be used to endorse or promote products derived
 *       from this software without specific prior written permission.
 *
 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS" AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 */
package com.googlecode.attention.sms.pdu;

import com.googlecode.attention.util.IntValue;

/**
 * TP-Failure-Cause (TP-FCS).
 * <BR>
 * <BR>The TP-Failure-Cause field is used to report the reason for failure
 * to transfer or process a short message. It consists of a single octet
 * used as follows:
 * <BR>
 * <BR>
 * <TABLE BORDER="0">
 * <TR><TD>TP-FCS<BR>Value</TD><TD>Meaning</TD><TD>When</TD><TD>used</TD></TR>
 * <TR><TD>(Hex)</TD><TD></TD><TD>MO</TD><TD>MT</TD></TR>
 * <TR><TD>00 - 7F</TD><TD>Reserved</TD><TD></TD><TD></TD></TR>
 * <TR><TD>80 - 8F</TD><TD>TP-PID errors</TD><TD></TD><TD></TD></TR>
 * <TR><TD>80</TD><TD>Telematic interworking not supported</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>81</TD><TD>Short message Type 0 not supported</TD><TD><CENTER>x</CENTER></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>82</TD><TD>Cannot replace short message</TD><TD><CENTER>x</CENTER></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>83 - 8E</TD><TD>Reserved</TD><TD></TD><TD></TD></TR>
 * <TR><TD>8F</TD><TD>Unspecified TP-PID error</TD><TD><CENTER>x</CENTER></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>90 - 9F</TD><TD>TP-DCS errors</TD><TD></TD><TD></TD></TR>
 * <TR><TD>90</TD><TD>Data coding scheme (alphabet) not supported</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>91</TD><TD>Message class not supported</TD><TD></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>92 - 9E</TD><TD>Reserved</TD><TD></TD><TD></TD></TR>
 * <TR><TD>9F</TD><TD>Unspecified TP-DCS error</TD><TD><CENTER>x</CENTER></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>A0 - AF</TD><TD>TP-Command Errors</TD><TD></TD><TD></TD></TR>
 * <TR><TD>A0</TD><TD>Command cannot be actioned</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>A1</TD><TD>Command unsupported</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>A2 - AE</TD><TD>Reserved</TD><TD></TD><TD></TD></TR>
 * <TR><TD>AF</TD><TD>Unspecified TP-Command error</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>B0</TD><TD>TPDU not supported</TD><TD><CENTER>x</CENTER></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>B1 - BF</TD><TD>Reserved</TD><TD></TD><TD></TD></TR>
 * <TR><TD>C0</TD><TD>SC busy</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>C1</TD><TD>No SC subscription</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>C2</TD><TD>SC system failure</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>C3</TD><TD>Invalid SME address</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>C4</TD><TD>Destination SME barred</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>C5</TD><TD>SM Rejected-Duplicate SM</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>C6</TD><TD>TP-VPF not supported</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>C7</TD><TD>TP-VP not supported</TD><TD><CENTER>x</CENTER></TD><TD></TD></TR>
 * <TR><TD>C8 - CF</TD><TD>Reserved</TD><TD></TD><TD></TD></TR>
 * <TR><TD>D0</TD><TD>(U)SIM SMS storage full</TD><TD></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>D1</TD><TD>No SMS storage capability in (U)SIM</TD><TD></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>D2</TD><TD>Error in MS</TD><TD></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>D3</TD><TD>Memory Capacity Exceeded</TD><TD></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>D4</TD><TD>(U)SIM Application Toolkit Busy</TD><TD></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>D5</TD><TD>(U)SIM data download error</TD><TD></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>D6 - DF</TD><TD>Reserved</TD><TD></TD><TD></TD></TR>
 * <TR><TD>E0 - FE</TD><TD>Values specific to an application</TD><TD><CENTER>x</CENTER></TD><TD><CENTER>x</CENTER></TD></TR>
 * <TR><TD>FF</TD><TD>Unspecified error cause</TD><TD><CENTER>x</CENTER></TD><TD><CENTER>x</CENTER></TD></TR>
 * </TABLE>
 * <BR>
 * <BR>NOTE: Any reserved codes which are received should be treated as
 * an unspecified error cause. MT and MO refer to the overall mobile
 * terminated and mobile originated services; not the direction of
 * transmission of TP-FCS.
 * 
 * @author Stein Gunnar Bakkeby
 */
public class FCS extends IntValue {

  /* Static field values (Reserved values not included). */
  /*  Errors 0 - 127 Reserved. */
  
  /*  TP-PID Errors: 128 - 143 */
  /** TP-PID error: Telematic interworking not supported. */
  public static final int PID_TELEMATIC_INTERWORKING_NOT_SUPPORTED = 128;
  /** TP-PID error: Short message Type 0 not supported. */
  public static final int PID_SHORT_MESSAGE_TYPE_NOT_SUPPORTED     = 129;
  /** TP-PID error: Cannot replace short message. */
  public static final int PID_CANNOT_REPLACE_SHORT_MESSAGE         = 130;
  /*  TP-PID errors 131 - 142 Reserved. */
  /** TP-PID error: Unspecified TP-PID error. */
  public static final int PID_UNSPECIFIED_ERROR                    = 143;
  
  /*  TP-DCS Errors: 144 - 159 */
  /** TP-DCS error: Data coding scheme (alphabet) not supported. */
  public static final int DCS_ALPHABET_NOT_SUPPORTED               = 144;
  /** TP-DCS error: Message class not supported. */
  public static final int DCS_MESSAGE_CLASS_NOT_SUPPORTED          = 145;
  /*  TP-DCS errors 146 - 158 Reserved. */
  /** TP-DCS error: Unspecified TP-DCS error. */
  public static final int DCS_UNSPECIFIED_ERROR                    = 159;  
  
  /*  COMMAND Errors: 160 - 175 */
  /** COMMAND error: Command cannot be actioned. */
  public static final int COMMAND_CANNOT_BE_ACTIONED               = 160;  
  /** COMMAND error: Command unsupported. */
  public static final int COMMAND_NOT_SUPPORTED                    = 161;
  /*  COMMAND errors 162 - 174 Reserved. */
  /** COMMAND error: Unspecified TP-Command error. */
  public static final int COMMAND_UNSPECIFIED_ERROR                = 175;
  
  /** TPDU not supported. */
  public static final int TPDU_NOT_SUPPORTED                       = 176;
  
  /*  Errors 177 - 191 Reserved. */
  
  /** SC busy. */
  public static final int SC_BUSY                                  = 192;
  /** No SC subscription. */
  public static final int NO_SC_SUBSCRIPTION                       = 193;
  /** SC system failure. */
  public static final int SC_SYSTEM_FAILURE                        = 194;
  /** Invalid SME address. */
  public static final int INVALID_SME_ADDRESS                      = 195;
  /** Destination SME barred. */
  public static final int DESTINATION_SME_BARRED                   = 196;
  /** SM Rejected-Duplicate SM. */
  public static final int SM_REJECT_DUPLICATE_SM                   = 197;
  /** TP-VPF not supported. */
  public static final int VPF_NOT_SUPPORTED                        = 198;
  /** TP-VP not supported. */
  public static final int VP_NOT_SUPPORTED                         = 199;
  /*  Errors 200 - 207 Reserved. */
  
  /** (U)SIM SMS storage full. */
  public static final int SIM_SMS_STORAGE_FULL                     = 208;
  /** No SMS storage capability in (U)SIM. */
  public static final int NO_SMS_STORAGE_CAPACITY_IN_SIM           = 209;
  /** Error in MS. */
  public static final int ERROR_IN_MS                              = 210;
  /** Memory Capacity Exceeded. */
  public static final int MEMORY_CAPACITY_EXCEEDED                 = 211;
  /** (U)SIM Application Toolkit Busy. */
  public static final int SIM_APPLICATION_TOOLKIT_BUSY             = 212;
  /** (U)SIM data download error. */
  public static final int SIM_DATA_DOWNLOAD_ERROR                  = 213;
  /*  Errors 214 - 223 Reserved. */
  
  /*  Errors 224 - 254 Application specific. */
  /** Unspecified error cause. */
  public static final int UNSPECIFIED_ERROR_CAUSE                  = 255;
  /* End static field values. */
  
  /**
   * Default constructor, creates an FCS that indicates an unspecified
   * error cause.
   */
  public FCS() {
    value = UNSPECIFIED_ERROR_CAUSE; // default (unspecified)
  }
  
  /**
   * Inherited constructor from IntValue.
   * @param value The value of this object
   */
  public FCS(final int value) {
    super(value);
  }
  
  /**
   * Inherited constructor from IntValue.
   * @param hex The value of this object in hex
   */
  public FCS(final String hex) {
    super(hex);
  }
  
  /**
   * This will set the FCS value. 
   * 
   * @param value Integer that must be in the range of 0 - 255
   * @throws IllegalArgumentException If num not in range 0 - 255
   */
  public void setValue(final int value) {
    if (value < 0 || value > 255) {
      throw new IllegalArgumentException("Integer not within range 0 - 255!");
    }
    this.value = value;
  }
}